package com.example.shop.mapper;

import com.example.shop.entity.Goods;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2025/9/2 21:41
 **/
@Mapper
public interface GoodsMapper {

    @Insert("""
INSERT INTO mi_goods (goods_id, category_id, shop_id, tag_type, title, cover_image_id,
market_price, price, sale_time, stock, is_sold_out, create_time, update_time, operator_id, is_delete) 
VALUES (#{goodsId}, #{categoryId}, #{shopId}, #{tagType}, #{title}, #{coverImageId}, #{marketPrice}, #{price},
#{saleTime}, #{stock}, #{isSoldOut}, now(), now(), null, 0);
""")
    void addGoods(Goods goods);

    @Select("""
select * from mi_goods where goods_id = #{goodsId} and is_delete = 0
""")
    Goods queryGoodsById(String goodsId);

    @Select("""
select * from mi_goods where is_delete = 0
""")
    List<Goods> queryGoodsList();
}
